package com.tianji.learning.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 *
 * @Author whx
 * @Date 2024/11/28 15:24
 */
@Configuration
public class RabbitMQConfiguration {

    @Bean
    public Queue ttlQueue(){
        return QueueBuilder
                .durable("ttl.queue")
                .deadLetterExchange("dl.exchange")
                .deadLetterRoutingKey("dl.key")
                .build();
    }

    @Bean
    public TopicExchange ttlExchange(){
        return ExchangeBuilder.topicExchange("ttl.exchange").build();
    }

    @Bean
    public Binding tlBinding(){
        return BindingBuilder.bind(ttlQueue()).to(ttlExchange()).with("ttl.key");
    }

}
